<template>
  <div>
    <el-form inline @submit.native.prevent>
      <el-form-item>
        <el-input v-model="form.name" placeholder="请输入用户的手机号" @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" :disabled="disabled" @click="handleQuery">查询用户方案</el-button>
      </el-form-item>
    </el-form>
    <div v-loading="loading">
      <div v-if="!data.user">
        暂无结果
      </div>
      <div v-if="data.user">
        <Result :data="data" />
      </div>
    </div>
  </div>
</template>

<script>
import { TableMixin } from '../../../components/mixin'
import { query } from '../../../api/query'

export default {
  components: {
    Result: () => import('../generate/result')
  },
  mixins: [TableMixin],
  data() {
    return {
      form: {
        name: ''
      },
      data: {},
      loading: false,
      disabled: false
    }
  },
  mounted() {
    // this.getList()
  },
  methods: {
    getList() {
      // this.wrapResourceList(getList, {})
    },
    handleQuery() {
      this.loading = true
      query({
        mobile: this.form.name
      }).then(res => {
        console.log(res)
        if (!res.result) {
          this.$message.error('没有找到填报方案')
        } else {
          this.data = res
        }
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>

<style scoped>

</style>
